GDIR=../../..
GIMDIR=$(GDIR)
LNMDIR=$(GDIR)/LnMlib/src
GIMIPATH=$(GDIR)/GIMI
MACIPATH=$(GDIR)/MaCI

CC=gcc
CXX=g++
CFLAGS=-Wall $(DEBUG) $(DEFINITIONS) $(CINCLUDES) $(CMISCFLAGS)
CPPFLAGS=-Wall $(DEBUG) $(EXCEPTIONS) $(CPPINCLUDES) $(DEFINITIONS) $(CPPMISCFLAGS)
DEBUG=-O2 -g3
CMISCFLAGS=
CPPMISCFLAGS=-DGIMI_CLIENT_API=10303
DEFINITIONS=-DLINUX_OS -DGIMI_NO_DATATYPE_INCLUDES
EXCEPTIONS=-fexceptions -ffast-math 
CINCLUDES=-I. -I$(GDIR)/utils
CPPINCLUDES=-I. $(OCCU_INCLUDE) -I$(GDIR)/glutImageGUI -I$(GDIR)/utils \
						-I$(GIMDIR)/ImageUtils/JPEGEncoder \
						`xml2-config --cflags` \
						-I$(GIMBOPATH)/components/MaCI_Player/players \
						$(MACI_INCLUDE_PATHS) \
						$(INCGIMI) -I$(LNMDIR)/utils $(LNM_UTIL_INCLUDE)

LD=g++
LDFLAGS=
LIBS=-lrt -lpthread -lGL -lGLU -lglut -ljpeg `xml2-config --libs` -lmrpt-core

SRCSC=
VPATH=
CPPGIMI=
CGIMI=

include $(MACIPATH)/interfaces/MaCI-interfaces.Makefile
include $(GIMIPATH)/Makefile.gimi
include $(LNMDIR)/map/Makefile.occu 
include $(LNMDIR)/utils/Makefile.util
#CSRCUTIL = $(GIMDIR)/utils/ownutils.c $(GIMDIR)/utils/owndebug.c
#CPPIMAGEGUI = $(GIMDIR)/glutImageGUI/glutImageGUI.cpp  $(GIMDIR)/ImageUtils/JPEGEncoder/JPEGEncoder.cpp

#SRCSCPP=$(CPPIMAGEGUI) $(OCCU_SRC_CPP)

## Construct final lists of CPP and C objects
OBJSC=$(SRCSC:.c=.o) $(CGIMI:.c=.o)
OBJSCPP=$(SRCSCPP:.cpp=.opp) \
	$(CPPGIMI:.cpp=.opp) \
	$(MACI_BASE_SRC_CPP:.cpp=.opp) \
	$(MACI_EXT_SRC_CPP:.cpp=.opp) \
	$(MACI_INTERFACE_RANGING_COMMON_CPP:.cpp=.opp)\
	$(MACI_INTERFACE_RANGINGSERVER_CPP:.cpp=.opp)\
	$(MACI_INTERFACE_POSITION_COMMON_CPP:.cpp=.opp)\
	$(MACI_INTERFACE_POSITIONSERVER_CPP:.cpp=.opp) \
	$(UTIL_SRC_CPP:.cpp=.opp) \
	$(MACIPATH)/utils/InterfaceFileLoggersAndReaders/PositionFileWriter.opp \
	$(MACIPATH)/utils/InterfaceFileLoggersAndReaders/PositionFileReader.opp \
	$(MACIPATH)/utils/InterfaceFileLoggersAndReaders/RangingFileReader.opp \
	$(MACIPATH)/utils/InterfaceFileLoggersAndReaders/RangingFileWriter.opp
	

## Define compiles and links
COMPILEC=$(CC) $(CFLAGS) $(CINCLUDES) -c
COMPILECPP=$(CXX) $(CPPFLAGS) $(CPPINCLUDES) -c
LINK=$(LD) $(LDFLAGS) $(LIBS)

.PHONY: all clean

TARGETS=MaCI2Rawlog OpenLogAddEstimateAndSave

all: $(TARGETS)

						
MaCI2Rawlog: $(OBJSC) $(OBJSCPP) MaCI2Rawlog.opp
			@$(LINK) -o $@ $^ $(LIBS)
			@echo "      [LD] $@"
OpenLogAddEstimateAndSave: $(OBJSC) $(OBJSCPP) OpenLogAddEstimateAndSave.opp
		@$(LINK) -o $@ $^ $(LIBS)
		@echo "      [LD] $@"

clean:
	rm -f $(OBJSC) $(OBJSCPP) *.opp *.o $(TARGETS) \
 		*.out *~ *.d *.dpp

## Compile rule for all .o (.c) file
%.o:    %.c
				$(COMPILEC) -o $@ $<

## Compile rule for all .opp (.cpp) files
%.opp:	%.cpp
				$(COMPILECPP) -o $@ $<
